const { defineConfig } = require("@vue/cli-service");
const path = require("path");

// 修改 resolve 函数以返回正确的绝对路径
function resolve(dir) {
  return path.resolve(__dirname, dir);
}

module.exports = defineConfig({
  transpileDependencies: true,
  chainWebpack: (config) => {
    config.module.rule("svg").exclude.add(resolve("src/icons")).end();

    config.module
      .rule("icons")
      .test(/\.svg$/)
      .include.add(resolve("src/icons")) // 确保这里是一个有效的路径
      .end()
      .use("svg-sprite-loader")
      .loader("svg-sprite-loader")
      .options({ symbolId: "icon-[name]" });
  },
});
